package com.xyd.servlet;

import com.xyd.entity.Admin;
import com.xyd.entity.Message;
import com.xyd.service.AdminService;
import com.xyd.service.impl.AdminServletImpl;
import org.apache.ibatis.annotations.Result;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author 86186
 */
@WebServlet("/AdminRegServlet")
public class AdminRegServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String eaName=request.getParameter("eaName");
        String eaPassword=request.getParameter("eaPassword");


        AdminService adminService=new AdminServletImpl();
        Admin admin=new Admin();
        admin.setEaName(eaName);
        admin.setEaPassword(eaPassword);
        Boolean flag=adminService.RegAdmin(admin);
        PrintWriter out=response.getWriter();

        out.print(flag);

        /*if (flag){

            response.sendRedirect("manage/index.html");

        }
        else {
            response.sendRedirect("manage/index.html");
        }*/

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
